<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>物料明细管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
		function clearForm(){
			$("#name").val('');
		}
		
		var check_val = [];
		//全选
		function selectAll(n){
			
			if(n.checked){
				check_val = []
				$("input[type=checkbox]").each(function(i,n) {
					if(i>0){
						this.checked = true; 
				        check_val.push(n.value)
					}
		        });  
			}else{
				$("input[type=checkbox]").each(function(i,n) {  
		            this.checked = false; 
		            check_val = []
		        });
			}
		}
		//单选
		function check(n){
		
			if(n.checked){
				check_val.push(n.value)
			}else{
				check_val.splice($.inArray(n.value,check_val),1)
			}
		}
		
		//批量删除
		function deleteAll(){
			
			if(check_val==null||check_val ==''||check_val==undefined){
				alertx("请选中删除的货品信息");
				return false;
			}
			return confirmx('确认要删除该货品信息吗？',"${ctx}/ka/materialDetails/deleteAll?ids="+check_val);
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/ka/materialDetails/">物料明细管理列表</a></li>
		<shiro:hasPermission name="ka:materialDetails:edit"><li><a href="${ctx}/ka/materialDetails/form">物料明细管理添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="materialDetails" action="${ctx}/ka/materialDetails/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>物料名称：</label>
				<form:input path="name" htmlEscape="false" maxlength="32" class="input-medium"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="button" onclick="clearForm()" value="重置"/></li>
			<li class="clearfix"></li>
		</ul>
		<shiro:hasPermission name="ka:materialDetails:delete">
			</br>
			<ul class="ul-form">
				<li class="btns"><label></label><input id="btnDelete" class="btn btn-primary" type="button" onclick="deleteAll()" value="批量删除"/></li>
				<li class="clearfix"></li>
			</ul>
		</shiro:hasPermission>	
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th><input type="checkbox" name="ck" onclick="selectAll(this)"></th>
				<th>物料名称</th>
				<th>数量</th>
				<shiro:hasPermission name="ka:materialDetails:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="materialDetails">
			<tr>
				<td>
					<input type="checkbox" value ="${materialDetails.id }" onclick="check(this)">
				</td>
				<td><a href="${ctx}/ka/materialDetails/form?id=${materialDetails.id}">
					${materialDetails.name}
				</a></td>
				<td>
					${materialDetails.amount}
				</td>
				<td>
    				<shiro:hasPermission name="ka:materialDetails:edit"><a href="${ctx}/ka/materialDetails/form?id=${materialDetails.id}">修改</a></shiro:hasPermission>
					<shiro:hasPermission name="ka:materialDetails:delete"><a href="${ctx}/ka/materialDetails/delete?id=${materialDetails.id}" onclick="return confirmx('确认要删除该物料明细管理吗？', this.href)">删除</a></shiro:hasPermission>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>